package com.qfmy.web.app.controller.novel;

import com.qfmy.common.result.Result;
import com.qfmy.model.entity.novel.CommentReplies;
import com.qfmy.model.vo.novel.CommentRepliesVo;
import com.qfmy.web.app.service.novel.CommentRepliesService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author 清风明月
 * @Package com.qfmy.web.app.controller.novel
 * @date 2025/10/31
 * @description 评论回复表
 */
@RestController
@RequestMapping("/app/commentReplies")
public class CommentRepliesController {

    /**
     * 注入service
     */
    @Autowired
    private CommentRepliesService commentRepliesService;

    /**
     * 添加评论
     */
    @RequestMapping("/addCommentReplies")
    public Result addCommentReplies(@RequestBody  CommentReplies commentReplies) {
        commentRepliesService.addCommentReplies(commentReplies);
        return Result.ok();
    }

    /**
     * 分页获取所有的评论
     */
    @RequestMapping("/getCommentRepliesByCommentId")
    public Result<List<CommentRepliesVo>> getCommentRepliesByCommentId(@RequestParam Integer commentId) {
        //获取所有的评论
        List<CommentRepliesVo> list = commentRepliesService.getCommentRepliesByCommentId(commentId);
        return Result.ok(list);
    }

    /**
     * 根据评论id删除评论
     */
    @RequestMapping("/deleteCommentReplies")
    public Result deleteCommentReplies(@RequestParam Integer id) {
        commentRepliesService.deleteCommentReplies(id);
        return Result.ok();
    }

    /**
     * 根据评论id判断用户是否评论
     */
    @RequestMapping("/isCommentReplies")
    public Result<Boolean> isCommentReplies(@RequestParam Integer commentId) {
        return Result.ok(commentRepliesService.isCommentReplies(commentId));
    }

}
